package dao;

import bean.Seat;
import util.Linksql;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class SeatDaoImpl{
    Connection connection=null;
    Statement std=null;
    ResultSet resultSet=null;
    public List<Seat> getAll() {
        connection=Linksql.getConnection();
        List list = new ArrayList();
        String sql = "select * from seat_funm";
        try{
        std=connection.createStatement();
        resultSet = std.executeQuery(sql);
        while (resultSet.next()){
            Seat seat = new Seat();
            seat.setSeatnum(resultSet.getString("seatnum"));
            seat.setUsestatus(resultSet.getString("usestatus"));
            seat.setAreaname(resultSet.getString("areaname"));
            seat.setFnum(resultSet.getString("fnum"));
            list.add(seat);
        }
            resultSet.close();
            std.close();
            connection.close();
    } catch (SQLException throwables){
            throwables.printStackTrace();
        }
        return list;
    }
}
